package com.tuling.jvm;
// JVM设置
// -Xms10M -Xmx10M -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\jvm.dump
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class OOMTest {
    public static List<Object> arrayList = new ArrayList<>();
    public static void main(String[] args) {
        List list = new ArrayList<>();
        int i = 0;
        int j = 0;
        while (true){
            list.add(new User(i++, UUID.randomUUID().toString()));// 此对象不会被回收
            new User(j--,UUID.randomUUID().toString());// 此对象会被回收 仅触发一次finalize()
        }
    }
}
